<%@ page import="lf.day0109.lottery.dao.LotteryDao" %>
<%@ page import="lf.day0109.lottery.impl.LotteryDaoImpl" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="lf.day0109.lottery.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: 19256
  Date: 2023/1/9
  Time: 11:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>燃油汽车指标摇号系统</title>
    <link rel="stylesheet" type="text/css" href="../../../css/lf/lottery/lottery.css" />
    <script type="text/javascript" src="../../../js/lf/lottery/jquery-3.6.3.js"></script>
    <script type="text/javascript" src="../../../js/lf/lottery/addUser.js"></script>
    <%
        //jsp组成部分: jsp小脚本  内置对象(9个内置对象)  jsp指令
        /*在jsp页面中获取后端Java程序,进行数据交互*/
        //1.使用多态体现,创建实例化LotteryDao数据访问层
        LotteryDao lotteryDao = new LotteryDaoImpl();
        //2.创建Map,,用来存储查询列表的搜索条件参数
        Map<String,Object> map = new HashMap<>();
        //2.1  获取indexController.jsp中存储在request作用域中的searchName
        String searchName = request.getAttribute("searchName") == null ? "":
                String.valueOf(request.getAttribute("searchName"));
        if(!"".equals(searchName)){
            map.put("userMarkNo",searchName);
        }
        //3.调用查询列表方法
        List<User> usersLists = lotteryDao.selectAll(map);

    %>
    <script type="javascript">
        var arrStatus = new Array("已持照","未持照");
    </script>
</head>
<body>
<div class="container">
    <div class="top">
        <h1>燃油汽车指标摇号系统</h1>
    </div>
    <div class="middle">
        <div class="left">
            <button onclick="location.href='yaohao.jsp'">参与摇号用户摇号</button>
        </div>
        <div class="right">
            <div class="top">
                <div class="leftButton">
                    <button onclick="location.href='add.jsp'">添加</button>
                </div>
                <div class="rightButton">
                    <form method="post" action="indexController.jsp">
                    <input type="text" placeholder="中签编码" name="search" id="search"/>
                    <button id="select" onclick="javascript:window.location.href='indexController.jsp'">搜索</button>
                    </form>
                </div>
            </div>
            <div class="middle">
                <ul>
                    <li>姓名</li>
                    <li>中签编码</li>
                    <li>持照状态</li>
                    <li>手机号码</li>
                    <li>开户日期</li>
                    <li>操作</li>
                </ul>
            </div>
                <div class="con">
                    <form method="post" action="deleteController.jsp">
                <%
                    for (int i = 0; i < usersLists.size(); i ++){
                        String status = usersLists.get(i).getStatus();
                        if ("0".equals(status)) {
                            status = "已持照";
                        } else {
                            status = "未持照";
                        }
                %>
                <ul>
                    <li><%=usersLists.get(i).getUserName()%></li>
                    <li><%=usersLists.get(i).getMarkNo()%></li>
                    <li><%=status%></li>
                    <li><%=usersLists.get(i).getPhone()%></li>
                    <li><%=usersLists.get(i).getOpenDate()%></li>
                    <li>
                        <a href="javascript:void(0);">详情</a>&nbsp;&nbsp;
                        <a href="javascript:void(0);" class="del">删除</a>
                    </li>
                </ul>
                <%    }   %>
                </form>
            </div>
        </div>
    </div>
</div>
</body>

</html>
